package com.cqq.print.business.service.impl;


import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqq.print.business.dao.PBookDao;
import com.cqq.print.business.dao.domain.PBook;
import com.cqq.print.business.service.PBookService;
import com.cqq.print.business.service.bean.PBookBean;


/**
 * @author CHENQQ
 * @date 2015-07-01
 */


@Service(value="pBookService")
public class PBookServiceImpl implements PBookService{

             @Autowired
             private PBookDao pBookDao;
             
			
			public int insertSelective(PBookBean bean) {
				if(bean==null)
					return 0;
				PBook pbook = new PBook();
				BeanUtils.copyProperties(bean, pbook);
				return pBookDao.insertSelective(pbook);
			}

			
			public int deleteByPrimaryKey(Integer id) {
				return pBookDao.deleteByPrimaryKey(id);
			}

			
			public PBookBean selectByPrimaryKey(Integer id) {
				PBook pbook = pBookDao.selectByPrimaryKey(id);
				if(pbook==null)
					return null;
				PBookBean bean = new PBookBean();
				BeanUtils.copyProperties(pbook,bean);
				return bean;
			}

			
			public int updateByPrimaryKeySelective(PBookBean bean) {
				if(bean==null||bean.getId()==null||bean.getId()<1)
					return 0;
				PBook pbook = new PBook();
				BeanUtils.copyProperties(bean, pbook);
				return pBookDao.updateByPrimaryKeySelective(pbook);
			}

}